package com.example.dmtprotocollib;

//import android.util.Log;



public class DmtProtocol{

	public static final int STATUS_OK					=0x0090		;// 成功

	public static final int STATUS_ERR_XOR				=0x8F01		;// XOR校验错误
	public static final int STATUS_ERR_SUM				=0x8F02		;// SUM校验错误
	public static final int STATUS_ERR_INS				=0x8F03		;// 指令错误
	public static final int STATUS_ERR_PARA				=0x8F04		;// 参数错误
	public static final int STATUS_ERR_INSTIMEOUT		=0x8F05		;// 指令执行超时
	public static final int STATUS_ERR_EXPARA			=0x8F06		;// 扩展域参数错误

	public static final int STATUS_ERR_OPEN				=0x8100		;// 打开模组失败
	public static final int STATUS_ERR_CLOSE			=0x8101		;// 关闭模组失败
	public static final int STATUS_ERR_RESET			=0x8102		;// 复位模组失败
	public static final int STATUS_ERR_STATE			=0x8103		;// 获取模组状态失败
	public static final int STATUS_ERR_VERSION 			=0x8107		;// 获取固件版本信息失败
	public static final int STATUS_ERR_UPDATE 			=0x810E		;// 固件更新使能失败

	public static final int STATUS_ERR_CFGKEY 			=0x8200		;// 设置密钥策略失败
	public static final int STATUS_ERR_SM2KEY1 			=0x8201		;// 设置SM2公钥1失败
	public static final int STATUS_ERR_SM2KEY2 			=0x8202		;// 设置SM2公钥2失败
	public static final int STATUS_ERR_SM4KEY1			=0x8203		;// 设置SM4主密钥失败
	public static final int STATUS_ERR_SM4KEY2			=0x8204		;// 设置SM4工作密钥失败

	public static final int STATUS_ERR_STARTSIGN		=0x8300		;// 设置密钥策略失败
	public static final int STATUS_ERR_CANCELSIGN		=0x8301		;// 设置SM2公钥1失败
	public static final int STATUS_ERR_ENDSIGN 			=0x8302		;// 设置SM2公钥2失败
	public static final int STATUS_ERR_GETSIGN			=0x8303		;// 设置SM4主密钥失败
	public static final int STATUS_ERR_GETENCSIGN		=0x8304		;// 设置SM4工作密钥失败


	public static final int STATUS_ERR_HANDLE			=0x1001		;// 设备错误
	public static final int STATUS_ERR_TIMEOUT			=0x1002		;// 通讯超时
	public static final int STATUS_ERR_OTHER			=0x1003		;// 错误的协议包

	public native static int CmdGetVersion(byte[] cmdpkt);
	public native static int RspGetVersion(byte[] respkt,byte[] vermsg);

	public native static int CmdOpen(byte[] p_cmd_pak,byte[]  cData);

	public native static int RspOpen(byte[] p_rsp_pak);

	//关闭
	public native static int CmdClose(byte[] p_cmd_pak);

	public native static int RspClose(byte[] p_rsp_pak);

	//复位
	public native static int CmdReset(byte[] p_cmd_pak);

	public native static int RspReset(byte[] p_rsp_pak);

	//取状态
	public native static int CmdGetStatus(byte[] p_cmd_pak);

	public native static int RspGetStatus(byte[] p_rsp_pak,byte[]  statusId, byte[]  statusMsg);

	// 使能固件更新
	public native static int CmdSetUpdate(byte[] p_cmd_pak);

	public native static int RspSetUpdate(byte[] p_rsp_pak);

	// 设置密钥策略
	public native static int CmdConfigKey (byte[] p_cmd_pak,byte keyType,byte keyMode);

	public native static int RspConfigKey(byte[] p_rsp_pak);

	// 传输SM2密钥1
	public native static int CmdTransSM2Key1(byte[] p_cmd_pak);

	public native static int RspTransSM2Key1(byte[] p_rsp_pak,byte[]  keyData);

	// 传输SM2密钥2
	public native static int CmdTransSM2Key2 (byte[] p_cmd_pak,byte[]  keyData);

	public native static int RspTransSM2Key2(byte[] p_rsp_pak);
	// 设置SM4主密钥
	public native static int CmdTransSM4Key1(byte[] p_cmd_pak,byte keyType, byte[]  keyData);

	public native static int RspTransSM4Key1(byte[] p_rsp_pak,byte keyType,byte[]  keyData);

	// 传输SM4工作密钥
	public native static int CmdTransSM4Key2 (byte[] p_cmd_pak,byte keyType, byte[]  keyData);

	public native static int RspTransSM4Key2(byte[] p_rsp_pak,byte keyType,byte[]  keyData);

	// 开始签字
	public native static int CmdStartSign(byte[] p_cmd_pak);

	public native static int RspStartSign(byte[] p_rsp_pak);

	// 取消签字
	public native static int CmdCancelSign(byte[] p_cmd_pak);

	public native static int RspCancelSign(byte[] p_rsp_pak);

	// 结束签字
	public native static int CmdEndSign(byte[] p_cmd_pak);

	public native static int RspEndSign(byte[] p_rsp_pak,int[] iSize);

	//上传签字数据
	public native static int CmdTransSign(byte[] p_cmd_pak);

	public native static int RspTransSign(byte[] p_rsp_pak,short[] signSize,byte[]  signData);

	//上传签字数据
	public native static int CmdTransEncSign(byte[] p_cmd_pak,byte[]  cData);

	public native static int RspTransEncSign(byte[] p_rsp_pak,short[] signSize,byte[]  signData);



	static {
		System.loadLibrary("dmtlib");
	}


}